package com.cdtye.itps.cms.service.lineSite;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cdtye.common.mybatiscore.base.BaseService;
import com.cdtye.itps.cms.dao.lineSite.entity.JcLineSite;
import com.cdtye.itps.cms.dao.lineSite.vo.JcLineSiteVo;
import com.cdtye.itps.cms.mapper.lineSite.JcLineSiteMapper;
import io.swagger.annotations.Api;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

@Service
@Api("段辖线路与区间站场关系 service")
public class JcLineSiteService extends BaseService<JcLineSiteMapper, JcLineSite> {


    @Autowired
    private JcLineSiteMapper baseMapper;
    /**
     * 获取所有的线路区站信息。注意类型是site
     * @return
     */
    public List<Map<String, Object>> getSites(){
        return baseMapper.getSites();
    }

    /**
     * 获取隶属于某条线路下的区站信息
     * @param vo
     * @return
     */
    public List<Map<String, Object>> getSiteByLines(JcLineSiteVo vo){
        if(vo.getSeclineId()!=null){
            vo.setSeclineIdList(Arrays.asList(vo.getSeclineId().split(",")));
        }
        return baseMapper.getSiteByLines(vo);
    }

    /**
     * 区间战场列表
     * @param vo
     * @return
     */
    public List<Map<String, Object>> getList(JcLineSiteVo vo){
        if(vo.getSeclineId()!=null){
            vo.setSeclineIdList(Arrays.asList(vo.getSeclineId().split(",")));
        }
        return baseMapper.getList(vo);
    }

    /**
     * 区间战场分页查询
     * @param vo
     * @return
     */
    public List<Map<String, Object>> pageList(IPage iPage, JcLineSiteVo vo){
        return baseMapper.pageList(vo.page(),vo);
    }

    public IPage<Map<String, Object>> pageList4Brain(JcLineSiteVo vo) {
        return baseMapper.pageList4Brain(vo.page(),vo);
    }
}
